#include "deep_sleep.h"
#include "driver/rtc_io.h"

#define DEEP_TAG "DEEP_SLEEP"

extern bool rtc_wakeup_flag;
static void deep_sleep_task(void *args)
{
    const int wakeup_time_sec = 5;
    ESP_ERROR_CHECK(esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1*1000 *1000));
    printf("Entering deep sleep\n");
    esp_deep_sleep_start();
}

void deep_sleep(void)
{
     // 设置唤醒标志
    rtc_wakeup_flag = true;
    xTaskCreate(deep_sleep_task, "deep_sleep_task", 4096, NULL, 6, NULL);
}
